using ProduceBasicData.Domain.Entities;
using System.ComponentModel.DataAnnotations;

namespace ProduceBasicData.Domain.CodeGeneration
{
    /// <summary>
    /// 编码生成规则实体
    /// </summary>
    public class CodeRule : BaseModel
    {
        /// <summary>
        /// 规则名称
        /// </summary>
        [Required]
        [MaxLength(100)]
        public string RuleName { get; set; } = string.Empty;

        /// <summary>
        /// 业务实体的完整限定名
        /// </summary>
        [Required]
        [MaxLength(200)]
        public string ClassFullName { get; set; } = string.Empty;

        /// <summary>
        /// 编码字段名
        /// </summary>
        [Required]
        [MaxLength(50)]
        public string CodeFieldName { get; set; } = string.Empty;

        /// <summary>
        /// 规则类型：年/年月/年月日/无
        /// </summary>
        [Required]
        public int RuleDateType { get; set; }

        /// <summary>
        /// 增长类型：每天重置/每月重置/每年重置/累计增长
        /// </summary>
        [Required]
        public int GrowthType { get; set; }

        /// <summary>
        /// 日期字段名（可选）
        /// </summary>
        [MaxLength(50)]
        public string? DateFieldName { get; set; }

        /// <summary>
        /// 编码前缀
        /// </summary>
        [Required]
        [MaxLength(10)]
        public string Prefix { get; set; } = string.Empty;

        /// <summary>
        /// 序号位数
        /// </summary>
        [Range(1, 4)]
        public int Digits { get; set; } = 4;

        /// <summary>
        /// 是否启用自动生成
        /// </summary>
        public bool IsEnabled { get; set; } = true;

        /// <summary>
        /// 规则描述
        /// </summary>
        [MaxLength(500)]
        public string? Description { get; set; }
    }
}
